fix: quiet -Walloc-size-larger-than and -Wformat-truncation warnings#436
Merged
thegushi merged 2 commits intoJun 23, 2026
Merged
Conversation
OPENDMARC_MAX_SHELVES_LG2 was derived from sizeof(size_t) under the assumption that OPENDMARC_HASH_SHELF is <= 32 bytes, but it actually holds a pthread_mutex_t and runs 48-72 bytes depending on platform, so the theoretical max calloc() request could exceed the allocator limit. The only real caller asks for 8192 buckets, so cap the table size at a fixed, generous bound instead. MAXHEADER was sized so that a maxed-out authservid_hdr plus a maxed-out From-domain could together exceed the malloc'd header buffer, risking silent truncation of the Authentication-Results header in pathological cases. Double it so the worst case fits.
test_arcares and test_spf_parse pull source files from $(top_srcdir)/opendmarc/, which automake warns will become a hard error in a future release without subdir-objects enabled. Verified make check still passes (13/13) with objects now placed in a path mirroring their source tree instead of being flattened.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OPENDMARC_MAX_SHELVES_LG2was derived fromsizeof(size_t)assumingOPENDMARC_HASH_SHELFis <= 32 bytes, but it holds apthread_mutex_tand actually runs 48-72 bytes depending on platform, so the theoretical maxcalloc()request inopendmarc_hash_init()could exceed the allocator limit (-Walloc-size-larger-than=). The only real caller asks for 8192 buckets, so cap the table size at a fixed, generous bound (16M) instead.MAXHEADER(4096) was small enough that a maxed-outauthservid_hdrplus a maxed-out From-domain could together exceed the malloc'd header buffer inopendmarc.c, risking silent truncation of theAuthentication-Resultsheader in pathological cases (-Wformat-truncation=). Doubled to 8192 so the worst case fits.Both warnings are pre-existing on
developand not specific to any in-flight feature branch; confirmed via the CI logs on PR #435.Test plan
makeinlibopendmarc/andopendmarc/succeeds locally (clang)-Walloc-size-larger-than=or-Wformat-truncation=for these two spots